#DEFINE vpCrLf CHR(13)+CHR(10)
#DEFINE vpUnicode 5
DECLARE INTEGER CreateDirectory IN kernel32;
		STRING lpPathName, STRING @lpSecurityAttr
		
#DEFINE IMAGE_BITMAP 0
#DEFINE LR_LOADFROMFILE 16
DECLARE INTEGER LoadImage IN user32;
		INTEGER hinst, STRING lpszName, INTEGER uType, ;
		INTEGER cxDesired, INTEGER cyDesired, INTEGER fuLoad
DECLARE INTEGER DeleteObject IN Gdi32;
		INTEGER ho
szSavePath = "C:\Argox"
szSaveFile = "C:\Argox\PPLB_Example.Prn"
sznop1     = "nop_front" + vpCrLf
sznop2     = "nop_middle" + vpCrLf
DECLARE integer B_Bar2d_Maxi in WINPPLB.DLL integer x, integer y, integer cl, integer cc, integer pc, ;
		string data_Renamed
DECLARE integer B_Bar2d_PDF417 in WINPPLB.DLL integer x, integer y, integer w, integer v, integer s, ;
		integer c, integer px, integer py, integer r, integer l, integer t, integer o, ;
		string data_Renamed
DECLARE integer B_Bar2d_PDF417_N in WINPPLB.DLL integer x, integer y, integer w, integer h, string para_Renamed, ;
		string data_Renamed
DECLARE integer B_Bar2d_DataMatrix in WINPPLB.DLL integer x, integer y, integer r, integer l, integer h, integer v, ;
		string data_Renamed
DECLARE B_ClosePrn in WINPPLB.DLL
DECLARE integer B_CreatePrn in WINPPLB.DLL integer selection, string filename
DECLARE integer B_Del_Form in WINPPLB.DLL string formname
DECLARE integer B_Del_Pcx in WINPPLB.DLL string pcxname
DECLARE integer B_Draw_Box in WINPPLB.DLL integer x, integer y, integer thickness, integer hor_dots, ;
		integer ver_dots
DECLARE integer B_Draw_Line in WINPPLB.DLL short mode, integer x, integer y, integer hor_dots, ;
		integer ver_dots
DECLARE integer B_Error_Reporting in WINPPLB.DLL short option
DECLARE  string B_Get_DLL_Version in WINPPLB.DLL integer nShowMessage
DECLARE integer B_Get_DLL_VersionA in WINPPLB.DLL integer nShowMessage
DECLARE integer B_Get_Graphic_ColorBMP in WINPPLB.DLL integer x, integer y, string filename
DECLARE integer B_Get_Graphic_ColorBMPEx in WINPPLB.DLL integer x, integer y, integer nWidth, integer nHeight, ;
		integer rotate, string id_name, string filename
DECLARE integer B_Get_Graphic_ColorBMP_HBitmap in WINPPLB.DLL integer x, integer y, integer nWidth, integer nHeight, ;
		integer rotate, string id_name, integer hbm
DECLARE integer B_Get_Pcx in WINPPLB.DLL integer x, integer y, string filename
DECLARE integer B_Initial_Setting in WINPPLB.DLL integer Type_Renamed, string Source
DECLARE integer B_WriteData in WINPPLB.DLL integer IsImmediate, string pbuf, integer length
DECLARE integer B_ReadData in WINPPLB.DLL string @pbuf, integer length, integer dwTimeoutms
DECLARE integer B_Load_Pcx in WINPPLB.DLL integer x, integer y, string pcxname
DECLARE integer B_Open_ChineseFont in WINPPLB.DLL string path_Renamed
DECLARE integer B_Print_Form in WINPPLB.DLL integer labset, integer copies, string form_out, ;
		string var_Renamed
DECLARE integer B_Print_MCopy in WINPPLB.DLL integer labset, integer copies
DECLARE integer B_Print_Out in WINPPLB.DLL integer labset
DECLARE integer B_Prn_Barcode in WINPPLB.DLL integer x, integer y, integer ori, string type_Renamed, ;
		integer narrow, integer width_Renamed, integer height_Renamed, short human, ;
		string data_Renamed
DECLARE B_Prn_Configuration in WINPPLB.DLL
DECLARE integer B_Prn_Text in WINPPLB.DLL integer x, integer y, integer ori, integer font_Renamed, ;
		integer hor_factor, integer ver_factor, short mode, string data_Renamed
DECLARE integer B_Prn_Text_Chinese in WINPPLB.DLL integer x, integer y, integer fonttype, ;
		string id_name, string data_Renamed
DECLARE integer B_Prn_Text_TrueType in WINPPLB.DLL integer x, integer y, integer FSize_Renamed, ;
		string FType, integer Fspin, integer FWeight, integer FItalic, integer FUnline, ;
		integer FStrikeOut, string id_name, string data_Renamed
DECLARE integer B_Prn_Text_TrueType_W in WINPPLB.DLL integer x, integer y, integer FHeight, ;
		integer FWidth, string FType, integer Fspin, integer FWeight, integer FItalic, ;
		integer FUnline, integer FStrikeOut, string id_name, string data_Renamed
DECLARE integer B_Select_Option in WINPPLB.DLL integer option
DECLARE integer B_Select_Option2 in WINPPLB.DLL integer option, integer p
DECLARE integer B_Select_Symbol in WINPPLB.DLL integer num_bit, integer symbol, integer country
DECLARE integer B_Select_Symbol2 in WINPPLB.DLL integer num_bit, string csymbol, integer country
DECLARE integer B_Set_Backfeed in WINPPLB.DLL short option
DECLARE integer B_Set_Backfeed_Offset in WINPPLB.DLL integer offset
DECLARE integer B_Set_CutPeel_Offset in WINPPLB.DLL integer offset
DECLARE integer B_Set_BMPSave in WINPPLB.DLL integer nSave, string strBMPFName
DECLARE integer B_Set_Darkness in WINPPLB.DLL integer darkness
DECLARE integer B_Set_DebugDialog in WINPPLB.DLL integer nEnable
DECLARE integer B_Set_Direction in WINPPLB.DLL short direction
DECLARE integer B_Set_Form in WINPPLB.DLL string formfile
DECLARE integer B_Set_Labgap in WINPPLB.DLL integer lablength, integer gaplength
DECLARE integer B_Set_Labwidth in WINPPLB.DLL integer labwidth
DECLARE integer B_Set_Originpoint in WINPPLB.DLL integer hor, integer ver
DECLARE integer B_Set_Prncomport in WINPPLB.DLL integer baud, short parity, integer data_Renamed, ;
		integer stop
DECLARE integer B_Set_Prncomport_PC in WINPPLB.DLL integer nBaudRate, integer nByteSize, ;
		integer nParity, integer nStopBits, integer nDsr, integer nCts, integer nXonXoff
DECLARE integer B_Set_Speed in WINPPLB.DLL integer speed
DECLARE integer B_Set_ProcessDlg in WINPPLB.DLL integer nShow
DECLARE integer B_Set_ErrorDlg in WINPPLB.DLL integer nShow
DECLARE integer B_GetUSBBufferLen in WINPPLB.DLL
DECLARE integer B_EnumUSB in WINPPLB.DLL string @buf
DECLARE integer B_CreateUSBPort in WINPPLB.DLL integer nPort
DECLARE integer B_ResetPrinter in WINPPLB.DLL
DECLARE integer B_GetPrinterResponse in WINPPLB.DLL string @buf, integer nMax
DECLARE integer B_TFeedMode in WINPPLB.DLL integer nMode
DECLARE integer B_TFeedTest in WINPPLB.DLL
DECLARE integer B_CreatePort in WINPPLB.DLL integer nPortType, integer nPort, string filename
DECLARE integer B_Execute_Form in WINPPLB.DLL string form_out, string var_Renamed
DECLARE integer B_Bar2d_QR in WINPPLB.DLL integer x, integer y, integer model, integer scl, ;
		short err, short dinput, integer c, integer d, integer p, string data_Renamed
DECLARE integer B_GetNetPrinterBufferLen in WINPPLB.DLL
DECLARE integer B_EnumNetPrinter in WINPPLB.DLL string @buf
DECLARE integer B_CreateNetPort in WINPPLB.DLL integer nPort
DECLARE integer B_Prn_Text_TrueType_Uni in WINPPLB.DLL integer x, integer y, integer FSize_Renamed, ;
		string FType, integer Fspin, integer FWeight, integer FItalic, integer FUnline, ;
		integer FStrikeOut, string id_name, string data_Renamed, integer format_Renamed
DECLARE integer B_Prn_Text_TrueType_UniB in WINPPLB.DLL integer x, integer y, integer FSize_Renamed, ;
		string FType, integer Fspin, integer FWeight, integer FItalic, integer FUnline, ;
		integer FStrikeOut, string id_name, string data_Renamed, integer format_Renamed
DECLARE integer B_GetUSBDeviceInfo in WINPPLB.DLL integer nPort, string @pDeviceName, ;
		integer @pDeviceNameLen, string @pDevicePath, integer @pDevicePathLen
DECLARE integer B_Set_EncryptionKey in WINPPLB.DLL string encryptionKey
DECLARE integer B_Check_EncryptionKey in WINPPLB.DLL string decodeKey, string encryptionKey, ;
		integer dwTimeoutms
DECLARE integer B_Set_CommTimeout in WINPPLB.DLL integer ReadTotalTimeoutConstant, ;
		integer WriteTotalTimeoutConstant
DECLARE integer B_Get_CommTimeout in WINPPLB.DLL integer @pReadTotalTimeoutConstant, ;
		integer @pWriteTotalTimeoutConstant
DECLARE integer B_Set_LabelForSmartPrint in WINPPLB.DLL integer lablength, ;
		integer gaplength		
		
MessageBox("Print Label", "PPLB Lib Example")
&& Test code start
&& open port.
PRIVATE nLen, ret, sw
PRIVATE pbuf, ver, strmsg
pbuf = Space(128)

&& dll version.
ver = B_Get_DLL_Version(0)

&& search port.
nLen = B_GetUSBBufferLen() + 1
strmsg = "DLL " + ver + vpCrLf   && only sample coding, not smart.
If nLen > 1
    PRIVATE buf1, buf2
    PRIVATE len1, len2
    len1 = 128
    len2 = 128
    buf1 = Space(len1)
    buf2 = Space(len2)
    B_EnumUSB(@pbuf)
    B_GetUSBDeviceInfo(1, @buf1, @len1, @buf2, @len2)
    sw = 1
    If 1 == sw
       ret = B_CreatePrn(12, buf2)   && open usb.
    Else
       ret = B_CreateUSBPort(1)   && must call B_GetUSBBufferLen() function fisrt.
    EndIf    
    If 0 < ret
        strmsg = strmsg + "Open USB fail!"
    Else
        strmsg = strmsg + "Open USB:" + vpCrLf + "Device name: "
        strmsg = strmsg + Left(buf1, len1)
        strmsg = strmsg + vpCrLf + "Device path: "
        strmsg = strmsg + Left(buf2, len2)
        && sw = 2
        If 2 == sw
          && Immediate Error Report.
          pbuf = "^ee\r\n"
          B_WriteData(1, pbuf, 5)   && ^ee
          ret = B_ReadData(@pbuf, 4, 1000)
        EndIf
    EndIf
Else
    CreateDirectory(szSavePath, null)
    ret = B_CreatePrn(0, szSaveFile)   && open file.
    strmsg = strmsg + "Open " + szSaveFile
    If 0 < ret
        strmsg = strmsg + " file fail!"
    Else
        strmsg = strmsg + " file succeed!"
    EndIf
EndIf
MessageBox(strmsg)
If 0 < ret
    Return
EndIf

&& sample setting.
B_Set_DebugDialog(1)
B_Set_Originpoint(0, 0)
B_Select_Option(2)
B_Set_Darkness(8)
B_Del_Pcx("*")   && delete all picture.
B_WriteData(0, sznop2, Len(sznop2))
B_WriteData(1, sznop1, Len(sznop1))
&& When using standard label, and the printer is Intelli Print mode or Smart Print mode,
&& When calling this function and giving the correct label information,
&& the immediate print function will be enabled according to the label length setting.
B_Set_LabelForSmartPrint(254 * 3, 30)  && abel information: length= 3 * 25.4 mm, gap= 3 mm.

&& draw box.
B_Draw_Box(20, 20, 4, 760, 560)
B_Draw_Line(ASC("O"), 400, 20, 4, 540)

&& print text, true type text.
B_Prn_Text(30, 40, 0, 2, 1, 1, ASC("N"), "PPLB Lib Example")
B_Prn_Text_TrueType(30, 100, 30, "Arial", 1, 400, 0, 0, 0, "AA", "TrueType Font")   && save in printer.
B_Prn_Text_TrueType_W(30, 160, 20, 20, "Times New Roman", 1, 400, 0, 0, 0, "AB", "TT_W: 多字元測試")

PRIVATE buff1
buff1 = STRCONV("TT_Uni: 多字元測試", vpUnicode)   && Converts double-byte characters to UNICODE(wide characters).
buff1 = buff1 + CHR(0) + CHR(0)   && null.
B_Prn_Text_TrueType_Uni(30, 220, 30, "Times New Roman", 1, 400, 0, 0, 0, "AC", buff1, 1)   && UTF-16

buff1 = CHR(255) + CHR(254)   && UTF-16.
buff1 = buff1 + STRCONV("TT_UniB: 多字元測試", vpUnicode)   && Converts double-byte characters to UNICODE(wide characters).
buff1 = buff1 + CHR(0) + CHR(0)   && null.
B_Prn_Text_TrueType_UniB(30, 280, 30, "Times New Roman", 1, 400, 0, 0, 0, "AD", buff1, 0)   && Byte Order Mark.

&& barcode.
B_Prn_Barcode(420, 100, 0, "3", 2, 3, 40, ASC("B"), "1234<+1>")   && have a counter.
B_Bar2d_QR(420, 200, 1, 3, ASC("M"), ASC("A"), 0, 0, 0, "QR CODE")

&& picture.
B_Get_Graphic_ColorBMP(420, 280, "bb.bmp")   && Color bmp file.
B_Get_Graphic_ColorBMPEx(420, 320, 200, 150, 2, "bb1", "bb.bmp")   && 180 angle.
PRIVATE himage
himage = LoadImage(0,"bb.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE)
B_Get_Graphic_ColorBMP_HBitmap(630, 280, 250, 80, 1, "bb2", himage)   && 90 angle.
If 0 != himage
	DeleteObject(himage)
EndIf

&& output.
B_Print_Out(2)   && copy 2.

&& close port.
B_ClosePrn()

clear dlls